System Hardware "People find gold in fields, veins, river beds and pockets. Whichever, it takes a lot of work to get it out." Art Linkletter 1965 Introduction Several areas of "the system" are covered in this chapter, specifically, the equipment, the memory, and the operating system. The equipment routines return information about the peripheral devices installed on the computer. The memory routines provide information about conventional, extended, and expanded memory and lastly the operating system routines provide information about, you guessed it, the operating system and the DOS configurable international settings. Determining System Hardware Disk Drives ParallelPorts: byte; Returns the number of installed parallel ports (LPTx). SerialPorts: byte; Returns the number of installed serial ports (COMx). FloppyDrives: byte; Returns the number of floppy drives physically installed on the system. LastDrv: integer; Beginning with DOS V3, this function returns a minimum last drive value equal to the number of logical drives or the LASTDRIVE value from the CONFIG.SYS file, whichever is greater. If there are only three logical drives and CONFIG.SYS does not specify a LASTDRIVE value, the default LASTDRIVE value of 5 is returned. If you need to determine the number of physical floppy drives attached to the system, use the function FloppyDrives, which returns this byte value. LogicalDriveNum( Drive: char ): byte; Converts a drive character to its logical drive equivalent. Drives A to Z are supported. (i.e. A = 0, B = 1, C = 2, ... ) PhysicalDriveNum( Drive: char ): byte; Converts a drive character to its physical drive equivalent. Drives A to Z are supported. (i.e. A = 1, B = 2, C = 3, ... ) DriveChar( Drive: byte ): char; Converts a byte value indicating the drive to be converted to its character equivalent. Byte values ranging from 0 to 26 are supported. (i.e. 0 = default, 1 = A, 2 = B, 3 = C, ...) IsPhantom: boolean; Since DOS will allow a user to switch to drive B whether or not it exists, it always looks more professional to a user to read a great PromptOK message about the drive not existing, rather than the infamous: INSERT DISKETTE IN DRIVE B: AND PRESS ENTER blasted across your custom designed screen. SetDriveTo( Drive: byte ); Eliminates "Insert diskette in drive" message. DriveExists(Drive: char): boolean; This is the preferred method of determining a drive's existence since it incorporates IsPhantom as a part of the determination. This function returns true if the specified drive physically exists. DriveIsReady( Drive: byte ): boolean; Returns true when the specified drive contains a correctly formatted readable diskette. This function actually looks at (seeks) the drive before making its determination, which is different from other related routines which make their determination by reading information contained in memory. CurrentDriveByte: byte; Returns a byte value of the current physical drive. CurrentDriveChar: char; Returns the character equivalent of the physical drive. CurrentPathStr: DirStr; Returns a string representing the current path on the current drive. This string excludes the final backslash. SetCurrentPath( NewPath: PathStr ): boolean; Returns a true value if the routine successfully changes to the path specified. ValidPath( Path: PathStr ): boolean; Returns true if the path specified is a valid path. Miscellaneous Display Routines Previous versions of the toolkit contained several routines that covered the display equipment within the Hardware unit. Due to the enhancements and methods of attaining information (and speed) most of these routines have been moved to the GOLDFAST unit. However, these remain simply because of how the information is retrieved. GetDispMode: byte; Returns the current display mode, e.g. mode 3 is 80 column mode. Refer to the Pascal Programmers Guide or a DOS Technical Reference for more information about display modes. ColorScreen: boolean; Returns true if the system is capable of supporting a color display. This function is normally called to determine whether to use monochrome or color attributes when overriding the toolkit's defaults. This function will always return false if HardVars.ForceBW is set to true. It also returns false if the user is using a color system, but has set the device to BW80 mode. Media Serial Numbers Beginning with DOS 4.0, any media being formatted has a serial number written to it. This serial number is a longint value contained in the Boot Parameter Block (BPB). If you inspect the very first piece of a diskette, you can actually pick it out by counting backwards 8 bytes from the beginning of the volume label. This will be the first byte of the serial number. The serial number, if placed by the FORMAT program, is a unique value made up of the system date and time. You may retrieve or modify this serial number to your liking by using the following two functions: GetMediaSerialNumber( Drive: byte ): string; Returns a string representing the serial number placed on the designated drive. The drive byte is passed as a physical value, i.e. 0 = default drive, 1 = A, 2 = B, ... SetMediaSerialNumber( Drive: byte;Serial: longint ): boolean; Although the proper way to set the serial number on a floppy or fixed disk is to format the disk, it may be set manually using this function. The longint value passed is converted to its hexadecimal representation and written to disk. An example of setting the serial number might look like this: Success := SetMediaSerialNumber(0, HEXStrToLong('01020304')); The Volume Label The volume label is actually stored in two places: the Boot Parameter Block (BPB) as an array of eleven bytes; also, as a file name entry but with the attribute assignment indicating that it is a volume label. DOS handles making the appropriate changes. GetVolumeLabel( Drive: byte ): string; Returns a string representing the volume label of the Drive designated. SetVolumeLabel( Drive: byte; LabelStr: Str12 ): byte; Writes a new volume label to the designated drive. DeleteVolumeLabel( Drive: byte ): byte; Removes the volume label from the designated drive. MediaIsLabeled( Drive: byte ): boolean; Returns true if a volume label is located on the designated drive. LabelIsCorrect( Drive: byte; LabelName: string ): LabelStatus; Compares the volume label specified to the volume label on the specified drive and returns a label status. LabelStatus is declared as an enumerated type that contains three members, CorrectLabel, NoLabel, IncorrectLabel. This can be used to check or validate volume labels for various reasons. System Specific OSVersion(Major:boolean): byte; If Major is a true value, then the major DOS version number, e.g. 3, 4, 5 or 6 is returned, otherwise the minor DOS version number is returned. OSVersionStr: string; Returns a full DOS version number, e.g. "6.22". ComputerID: byte; This function returns a byte indicating the basic system type. The computer ID was implemented by IBM to provide an easy way for differentiating between the various IBM personal computers. The following list shows the hexadecimal values of the IBM range: $FF - IBM PC $FE,$FB - IBM XT or portable $FD - the infamous PC Junior $FC - IBM AT, XT-286, PS/2 50 and 60 $FA - PS/2 25 and 30 $F9 - IBM PC Convertible $F8 - PS/2 80 Some non-IBM systems do not follow this convention, an unlisted number may be returned by this method. ROMDate: string; Returns an eight character string representing the ROM date in the format MM/DD/YY. GameAdapter: boolean; Returns true if a game adapter is installed. SerialPrinter: boolean; Returns true if a serial printer is configured. MathChip: boolean; Returns true if a math co-processor is detected. If you compile toolkit programs with the compiler directive FLOAT enabled, but FLOATEM disabled, the program will only run on systems equipped with a math co-processor. Use this function during program initialization to ensure the host PC is adequately equipped. OSVersionMajor: byte; Returns the major DOS version number, e.g. 3, 4, 5 or 6. OSVersionMinor: byte; Returns the minor DOS version number, e.g. 1. Country: word; Returns a word which represents the country code. In general, the country codes are the same as the 3-digit international phone access code. Some of the common codes are: 001 United States 002 Canada (French) 003 Latin America 031 Netherlands 032 Belgium 033 France 034 Spain 039 Italy 041 Switzerland 044 United Kingdom 045 Denmark 046 Sweden 047 Norway 049 Germany 061 Australia 351 Portugal 358 Finland Currency: string; Returns a string identifying the country's currency abbreviation. On systems using DOS prior to version 3.0, only a single character can be accessed. However, systems using DOS 3.0 and later may return more than one character, e.g. FFR, DKR. DateFmt: OSDate; Returns the gDate enumerated type member which represents the operating system default date format. The GOLDHARD unit includes the enumerated type gDate which has three members: USA, EUROPE, and JAPAN. The three formats are MM-DD-YY, DD-MM-YY, and YY-MM-DD, respectively. ThousandsSep: char; Returns the character used to punctuate the thousands mark in numbers. The USA uses a comma, whereas some other countries use a period or a space. DecimalSep: char; Returns the character used to punctuate the decimal place. This is usually a period or a comma. DateSep: char; Returns the character used to separate the month, day, and year elements of a date. This information is not available on systems using DOS versions less than 3.0. If this information is not available a '/' is returned. TimeSep: char; Returns the character used to separate the hours, minutes and seconds when displaying the time. This information is not accessible on systems using DOS prior to version 3.0. If the machine does not have DOS 3.0 or later, a 0 is returned. TimeFmt: byte; Returns a byte to indicate the preferred time display. A 0 indicates a 12 hour format, and a 1 indicates a 24 hour format. This information is not accessible on systems using DOS prior to version 3.0. If the machine does not have DOS 3.0 or later, a 0 is returned. CurrencyFmt: byte; Returns a byte indicating the currency format. One of the following five values will be returned: 0 String leads currency, no space 1 String follows currency, no space 2 String leads currency, one space 3 String follows currency, one space 4 String replaces decimal separator NOTE: This information is not accessible on systems using DOS prior to version 3.0. If the machine does not have DOS 3.0 or later, a 0 is returned. CurrencyDecPlaces: byte; Returns the number of decimal places normally used with the country's currency. This information is not accessible on systems using DOS prior to version 3.0. If the machine does not have DOS 3.0 or later, a 2 is returned. Memory Specific BaseMemory: integer; Returns the total amount of base memory installed, i.e. memory up to 640K. The value is returned in kilobytes ("k"). Remember to use the other toolkit functions GoldMemAvail and GoldMaxAvail to provide data on free memory, i.e. memory not being used by device drivers and programs. EMMInstalled: boolean; Returns true if an expanded memory manager is installed. XMSInstalled: boolean; Returns true if an extended memory driver is installed. EMMVersionMajor: byte; Returns the expanded memory manager major version number, i.e. the whole portion of the version number. If an EMM is not installed, a 0 is returned. EMMVersionMinor: byte; Returns the expanded memory manager minor version number, i.e. the decimal portion of the version number. If an EMM is not installed, or if the minor version number is a zero, a 0 is returned. EMMVersion: string; Returns a three character string representing the complete EMM version number, e.g. "4.0". Encountering and Determining Errors LastHardError: integer; Returns the integer value of the last error that was detected in the GOLDHARD unit. A value of zero indicates no errors have been detected.